{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "hyyN-2qyK_T2"
      },
      "source": [
        "# Ruckig - Motion Generation for Robots and Machines\n",
        "\n",
        "Github Repo: [https://github.com/pantor/ruckig](https://github.com/pantor/ruckig)\n",
        "\n",
        "## Install Dependencies Using Pip\n",
        "\n",
        "\n",
        "```\n",
        "pip install ruckig\n",
        "```"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {},
        "colab_type": "code",
        "id": "gWskDE2c9WoN"
      },
      "outputs": [],
      "source": [
        "!pip install ruckig"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "FtY8FhliLsGm"
      },
      "source": [
        "## Import Ruckig"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 6,
      "metadata": {
        "colab": {},
        "colab_type": "code",
        "id": "BIedd7Pz9sOs"
      },
      "outputs": [],
      "source": [
        "from ruckig import Ruckig, InputParameter, Trajectory"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 7,
      "metadata": {
        "colab": {},
        "colab_type": "code",
        "id": "SpMDXP0vmezv"
      },
      "outputs": [],
      "source": [
        "ruckig = Ruckig(6, 0.001)\n",
        "\n",
        "inp = InputParameter(ruckig.degrees_of_freedom)\n",
        "\n",
        "inp.current_position = [0.1586916078246517, 0.8198410238869502, -0.2681910390107047, -0.09903812486505789, -1.795801648113672, 1.250459998705841]\n",
        "inp.current_velocity = [1.224365429569406, -0.8752573930094795, 0.6074060830631294, -0.7773969322150299, -0.6074782842272427, 2.794826109810867e-08]\n",
        "inp.current_acceleration = [12.36606404941746, 0, 0, 0, 0, 0]\n",
        "\n",
        "inp.target_position = [0.35257, 0.7036, -0.20583, -0.18096, -1.85703, 1.25046]\n",
        "inp.target_velocity = [0, 0, 0, 0, 0, 0]\n",
        "inp.target_acceleration = [0, 0, 0, 0, 0, 0]\n",
        "\n",
        "inp.max_velocity = [2.663652051520562, 1.555190266438036, 0.9215599306967612, 1.17514790481581, 0.9107239220283427, 2.794826109810866e-08]\n",
        "inp.max_acceleration = [49.44190521665187, 41.42429896530291, 54.7869760508845, 73.49472397069871, 72.82659011641964, 133.6267625041427]\n",
        "inp.max_jerk = [772.5298358235708, 647.254671332858, 856.0465007950703, 1148.355062042167, 1137.915470569057, 2087.918294622123]"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "eezphIrRmr-Y"
      },
      "source": [
        "### Offline Trajectory Generation"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {},
        "colab_type": "code",
        "id": "CQT1k7lWmmTL"
      },
      "outputs": [],
      "source": [
        "traj = Trajectory(ruckig.degrees_of_freedom)\n",
        "\n",
        "result = ruckig.calculate(inp, traj)\n",
        "\n",
        "print(f'Status: {result}')\n",
        "print(f'Trajectory duration: {traj.duration:0.4f} [s]')"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "collapsed_sections": [],
      "name": "ruckig.ipynb",
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
